package com.kfm.ajax.config;

import com.kfm.ajax.interceptor.PromisserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

@Configuration // 标记为配置类
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private PromisserInterceptor promisserInterceptor;

    private static final List<String> EXCLUDE_PATHS = Arrays.asList("/", "/login", "/captcha", "/error", "/css/**", "/js/**", "/layui/**", "/403");

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(promisserInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_PATHS);
    }
}
